package com.hzncc.scaffold.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.hzncc.scaffold.entity.Bo.JobListBo;
import com.hzncc.scaffold.entity.Other.Job;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hzncc.scaffold.entity.Vo.InsituteUserVo;
import com.hzncc.scaffold.entity.Vo.InstituteCenterJobListVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 职位表 Mapper 接口
 * </p>
 *
 * @author DrunkBear
 * @since 2022-04-27
 */
public interface JobMapper extends BaseMapper<Job> {


    @Select("SELECT\n" +
            "\t`Job`.`id`,\n" +
            "\t`Job`.`status`,\n" +
            "\t`Job`.`pubTime`,\n" +
            "\t`Job`.`title`,\n" +
            "\t`Job`.`type`,\n" +
            "\t`Job`.`province`,\n" +
            "\t`Job`.`city`,\n" +
            "\t`Job`.`district`,\n" +
            "\t`Job`.`address`,\n" +
            "\t`Job`.`stayAtTop`,\n" +
            "\t`Job`.`needNum`,\n" +
            "\t`Job`.`education`,\n" +
            "\t`Job`.`salary`,\n" +
            "\t`Job`.`content`,\n" +
            "\t`institute`.`id` AS `instituteId`,\n" +
            "\t`institute`.`name` AS `instituteName`,\n" +
            "\t`institute`.`role` AS `instituteRole` \n" +
            "FROM\n" +
            "\t`job` AS `Job`\n" +
            "\tLEFT OUTER JOIN `user` AS `institute` ON `Job`.`belongsTo` = `institute`.`id` \n" +
            "WHERE\n" +
            "\t`Job`.`status` = 1 \n" +
            "ORDER BY\n" +
            "\t`Job`.`stayAtTop` DESC,\n" +
            "\t`Job`.`sortTime` DESC,\n" +
            "\t`Job`.`pubTime` DESC ")
    public List<JobListBo> list();


    @Select("SELECT\n" +
            "\t`job`.*,\n" +
            "\t`cvposts`.`id` AS `cvpostsId` \n" +
            "FROM\n" +
            "\t(\n" +
            "\tSELECT\n" +
            "\t\t`job`.`id`,\n" +
            "\t\t`job`.`title`,\n" +
            "\t\t`job`.`type`,\n" +
            "\t\t`job`.`education`,\n" +
            "\t\t`job`.`salary`,\n" +
            "\t\t`job`.`address`,\n" +
            "\t\t`job`.`needNum`,\n" +
            "\t\t`job`.`createTime`,\n" +
            "\t\t`job`.`status`,\n" +
            "\t\t`job`.`province`,\n" +
            "\t\t`job`.`city`,\n" +
            "\t\t`job`.`district`,\n" +
            "\t\t`job`.`stayAtTop`,\n" +
            "\t\t`job`.`sortTime`,\n" +
            "\t\t`job`.`content` \n" +
            "\tFROM\n" +
            "\t\t`job` AS `Job` \n ${ew.customSqlSegment}" +
            "\tORDER BY\n" +
            "\t\t`job`.`stayAtTop` DESC,\n" +
            "\t\t`job`.`sortTime` DESC,\n" +
            "\t\t`job`.`id` DESC \n" +
            "\t) AS `job`\n" +
            "\tLEFT OUTER JOIN `cvpost` AS `cvposts` ON `job`.`id` = `cvposts`.`jobId` \n" +
            "ORDER BY\n" +
            "\t`job`.`stayAtTop` DESC,\n" +
            "\t`job`.`sortTime` DESC,\n" +
            "\t`job`.`id` DESC")
    public List<InstituteCenterJobListVo> instituteJobList(@Param(Constants.WRAPPER) QueryWrapper queryWrapper);
}
